/*
 * @Author: szx
 * @Date: 2021-10-22 14:21:45
 * @LastEditTime: 2021-10-22 14:25:42
 * @Description:
 * @FilePath: \leetcode\169\169.go
 */
package main

func majorityElement(nums []int) int {
	res, cnt := 0, 0
	for _, num := range nums {
		if cnt == 0 {
			res = num
			cnt++
		} else {
			if num == res {
				cnt++
			} else {
				cnt--
			}
		}
	}
	return res
}
func main() {
	var nums []int = []int{3, 2, 3}
	print(majorityElement(nums))
}
